<?php require('connections/con_gl.php'); ?>

<?php

cekAkses($_SESSION[akses],"PD-5-2");



$colname_edit = "-1";

if (isset($_GET['id'])) {

  $colname_edit = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);

}

mysql_select_db($database_con_gl, $con_gl);

$query_edit = sprintf("SELECT * FROM gl_tipekendaraan WHERE id = %s", $colname_edit);

$edit = mysql_query($query_edit, $con_gl) or die(mysql_error());

$row_edit = mysql_fetch_assoc($edit);

$totalRows_edit = mysql_num_rows($edit);

// --- get barang

mysql_select_db($database_con_gl, $con_gl);

$query_barang = "select a.id, a.barang from gl_barang a, gl_kelompok b where a.kelompok = b.id AND b.jenis='2' order by a.barang";

$barang       = mysql_query($query_barang, $con_gl) or die(mysql_error());

$row_barang   = mysql_fetch_assoc($barang);

$totalRows_barang = mysql_num_rows($barang);

//---

// get master barang

$query_ldata = "select a.id, b.barang, c.area, a.hargasewa, a.supir, a.bbm, a.tol, a.parkir, a.akomod, a.other from gl_jenbar a, gl_barang b, gl_area c where a.jenis='$_GET[id]' AND a.barang = b.id AND a.area= c.id order by b.barang";

$ldata       = mysql_query($query_ldata, $con_gl) or die(mysql_error());

$row_ldata   = mysql_fetch_assoc($ldata);

$total_ldata = mysql_num_rows($ldata);

?>

<link type="text/css" rel="stylesheet" href="css/jquery.wysiwyg.css" />

<script type="text/javascript" src="js/ajax_data.js"></script>

<script type="text/javascript" src="js/jquery.wysiwyg.js"></script>

<script type="text/javascript">

$(document).ready(function() {



	$().ajaxStart(function() {

		$('#loading').show();

		$('#result').hide();

	}).ajaxStop(function() {

		$('#loading').hide();

		$('#result').fadeIn('slow');

	});



	$('#edit').submit(function() {

		$.ajax({

			type: 'POST',

			url: $(this).attr('action'),

			data: $(this).serialize(),

			success: function(data) {

				$('#result').html(data);

			}

		})

		return false;

	});

  $('#result').click(function(){

  $(this).hide();

  });

})

$(function()

  {

	  $('#keterangan').wysiwyg();

  });

</script>

<div id="loading" style="display:none;"><img src="images/loading.gif" alt="loading..." /></div>

<div id="result" style="display:none;"></div>

<h1>Edit Paket Harga Sewa </h1>

<form action="proses/jenisservice.php?act=edit" method="POST" name="edit" id="edit" >

  <table width="100%" border="0" align="center" cellpadding="5" cellspacing="0" class="datatable">
    <tr valign="top">
      <td align="right" bgcolor="#FFFFFF">Tipe Kendaraan* : </td>
      <td bgcolor="#FFFFFF"><label>
        <input name="tipekendaraan" type="text" id="tipekendaraan" value="<?php echo $row_edit['tipekendaraan']; ?>" size="30" maxlength="100" />
      </label></td>
    </tr>
	
    <tr valign="top">

      <td width="12%" align="right" bgcolor="#FFFFFF"> Daftar Harga Paket :</td>

      <td width="88%" bgcolor="#FFFFFF"><div id="divMasterBarang"><table width="100%" border="0" cellspacing="0" cellpadding="4" class="datatable">

  <tr>
    <th>Paket Yang tersedia </th>
    <th>Area Ops </th>
    <th width="11%">Harga Sewa</th>
    <th width="9%">Jasa Supir</th>
    <th width="8%">BBM</th>
    <th width="8%">Tol</th>
    <th width="8%">Parkir</th>
    <th width="10%">Akomodasi</th>
    <th width="8%">Other</th>
    <th width="8%">Atur</th>
  </tr>

  <?php if($total_ldata > 0) { do { ?>

  <tr valign="top">

    <td width="18%"><?php echo $row_ldata['barang'];?> <a href="javascript:void(0);" onClick="ajaxManageMasterBarang('editform','<?php echo $row_ldata['id'];?>');" title="Edit Data"><img src="images/edit_.png" border="0" /></a></td>
    <td width="12%"><?php echo $row_ldata['area'];?></td>
    <td align="center"><?php echo number_format($row_ldata['hargasewa'],0,',','.');?></td>
    <td align="center"><?php echo number_format($row_ldata['supir'],0,',','.');?></td>
    <td align="center"><?php echo number_format($row_ldata['bbm'],0,',','.');?></td>
    <td align="center"><?php echo number_format($row_ldata['tol'],0,',','.');?></td>
    <td align="center"><?php echo number_format($row_ldata['parkir'],0,',','.');?></td>
    <td align="center"><?php echo number_format($row_ldata['akomod'],0,',','.');?></td>
    <td align="center"><?php echo number_format($row_ldata['other'],0,',','.');?></td>
    <td align="center"><a href="javascript:void(0);" onClick="ajaxManageMasterBarang('Hapus','<?php echo $row_ldata['id'];?>');"><img src="images/delete_.png" border="0" /></a></td>
  </tr>
  <?php }while($row_ldata = mysql_fetch_assoc($ldata)); } ?>

</table>
      </div></td>
    </tr>

    <tr valign="top">

      <td align="right" bgcolor="#FFFFFF">Setting Harga Paket*</td>

      <td bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="0" cellpadding="4" class="datatable">
        <tr>
          <th colspan="2">Paket</th>
          <th width="9%">Harga Sewa</th>
          <th width="10%">Jasa Supir</th>
          <th width="9%">BBM</th>
          <th width="9%">Tol</th>
          <th width="7%">Parkir</th>
          <th width="9%">Akomodasi</th>
          <th width="6%">Other</th>
          <th width="8%">Atur</th>
        </tr>
        <tr>
          <td width="14%"><label>
            
            <select name="barang" id="barang">
              
              <option value="">Pilih Paket Sewa</option>
              
              <?php if($totalRows_barang > 0) { do { ?>
              
              <option value="<?php echo $row_barang['id'];?>"><?php echo $row_barang['barang'];?></option>
              
              <?php }while($row_barang = mysql_fetch_assoc($barang)); } ?>
              </select>
            
          </label> &nbsp;&nbsp;</td>
          <td width="19%">	<?php list($idarea, $namaarea) = mysql_fetch_row(mysql_query("select id, area from gl_area where id = '$row_ldata[area]'")); ?>
	  <input type="hidden" name="area" id="area" value="<?php echo $idarea; ?>" />
	  <input type="text" name="txtarea" id="txtarea" size="20" value="<?php echo $namaarea; ?>" readonly style="background-color:#fff;border:1px solid #999; height:16px;" onclick="NewWindow('index.php?component=area&amp;task=listarea&amp;open=window','name','825','450','yes');return false" placeholder="Pilih Area.." />
        <?php if(strstr($_SESSION['akses'],"PD-6-1")) { ?>
        <a href="index.php?component=area&amp;task=add&amp;open=window" onclick="NewWindow(this.href,'name','825','450','yes');return false"><img src="images/add_.png" hspace="2" border="0" style="position:absolute;" /></a>
        <?php } ?></td>
          <td align="center"><label>
            <input name="harga" type="text" id="harga" value="0" size="8" maxlength="10" />
          </label></td>
          <td align="center"><label>
            <input name="supir" type="text" id="supir" value="0" size="8" maxlength="10" />
          </label></td>
          <td align="center"><label>
            <input name="bbm" type="text" id="bbm" value="0" size="8" maxlength="10" />
          </label></td>
          <td align="center"><label>
            <input name="tol" type="text" id="tol" value="0" size="8" maxlength="10" />
          </label></td>
          <td align="center"><label>
            <input name="parkir" type="text" id="parkir" value="0" size="8" maxlength="10" />
          </label></td>
          <td align="center"><label>
            <input name="akomodasi" type="text" id="akomodasi" value="0" size="8" maxlength="10" />
          </label></td>
          <td align="center"><label>
            <input name="other" type="text" id="other" value="0" size="8" maxlength="10" />
          </label></td>
          <td align="center">
          <a href="javascript:void(0);" onclick="ajaxManageMasterBarang('Tambah','');" title="Tambah Data"><img src="images/add_new.png" border="0" /></a>          </td>
        </tr>
      </table></td>
    </tr>

    <tr valign="top">

      <td align="right" bgcolor="#FFFFFF">Keterangan : </td>

      <td bgcolor="#FFFFFF"><label>

      <textarea name="keterangan" cols="85" rows="5" id="keterangan"><?php echo $row_edit['keterangan']; ?></textarea>

      <input name="id" type="hidden" id="id" value="<?php echo $row_edit['id']; ?>" />

      </label></td>
    </tr>

    

    <tr>

      <td align="left" bgcolor="#FFFFFF"><em>*Harus diisi</em></td>

      <td bgcolor="#FFFFFF"><label>

        <input name="Save" type="submit" id="Save" value="Simpan" />

        </label>

          <label>

          <input type="button" name="Button" value="Batal" onClick="javascript:history.go(-1);">
        </label></td>
    </tr>
  </table>

</form>

